package LeetCode;

import com.sun.scenario.effect.impl.state.LinearConvolveRenderState;

import java.util.ArrayList;
import java.util.List;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}16:43
 */
public class LeetCode914 {
    public static void main(String[] args) {
        int[] arr = {1,1};
        System.out.println(new LeetCode914().hasGroupsSizeX(arr));
    }

    public boolean hasGroupsSizeX(int[] deck) {
        int n = deck.length;
        //然后统计次数的数组
        int[] count = new int[10000];

        for (int i = 0 ; i < n; i++){//不能直接用数组来进行 约数的比较因为可能开头会有很多0;
            count[deck[i]]++;
        }

        List<Integer> list = new ArrayList<>();
        for (int i : count) {
            if (i != 0) {
                list.add(i);
            }
        }

        //判断排的X是否满足长度的公约数

        search:for (int i = 2; i <= n; i++){
            if (n % i == 0){
                for (int j : list){
                    if (j % i != 0){
                        continue search;
                    }
                }
                return true;
            }

        }
        return false;
    }
}
